import { app } from "./app";

import router from "./vue-router";
import { createPinia } from "pinia";

import "uno.css";
import "@/assets/style/global.scss";
import "@/assets/style/sim-theme.css";
import "@/assets/style/element.scss";

import "@/assets/icons";
import "element-plus/dist/index.css";

import VueKonva from "vue-konva";
app.use(VueKonva);

import { i18n } from "@/vue-i18n";
app.use(i18n);

// 导入视频播放组件
import VueVideoPlayer from "@videojs-player/vue";
import "video.js/dist/video-js.css";
app.use(VueVideoPlayer);

app.use(router).use(createPinia()).mount("#app");

// import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
//   app.component(key, component)
// }

import { userConfig } from "@/pages/pinia/user/index";
const userConfigStore = userConfig();

router.beforeEach((to, from, next) => {
  // 在导航前执行操作，例如身份验证检查
  if (to.meta.auth && !userConfigStore.hasLoggedIn) {
    next("/login"); // 重定向到登录页
  } else {
    next(); // 继续导航
  }
});
